<script src="<?php echo base_url() . 'assets/js/app/list.js'; ?>"></script>
<script src="<?php echo base_url() . 'assets/js/jquery-1.9.1.js'; ?>"></script>
<?php echo anchor(base_url(),"Home");?>
&nbsp
<?php echo anchor("user/User/create","Create");?>
<!--search meta data-->
<?php echo $meta_search_form;?>

<!--search by parent-->
<?php echo form_open("user/User/search_by_parent"); ?>
<table>
  <tr>
    <td><label for="role_id">Role</label></td>
    <td>
    	<select name="role_id" id="role_id">
    		<option value=""></option>
    	<?php foreach ($parent_list as $role) { ?>
    		<option value="<?php echo $role -> id; ?>" <?php echo set_select('role_id', $role->id)?> <?php
			if(count($params) > 0) {?>
				
				<?php
				if ($params['role_id'] == $role->id	)
					echo 'selected';
			}
		?>><?php 
		echo $role -> name; ?></option>
    	<?php } ?>
    	</select>
    </td>
  	<td><input type="submit" name="seach" value="Filter"/></td>
  </tr>
</table>
<?php echo form_close(); ?>
<!--End-->
<form action="<?php echo site_url('user/User/delete_all');?>" method="post" onsubmit="return is_check()">
<table>
  <tr>
  	<th><input type="checkbox" onClick="toggle(this)" /></th>
    <th align="left">Id</th>
    <th align="left">Username</th>
    <th align="left">First name</th>
    <th align="left">Last name</th>
    <th align="left">Email</th>
  </tr>
<?php if(isset($results)) : foreach($results as $row):?>
  <tr height="35" id="<?php echo "tr_data".$row -> id;?>" onmousemove ="show_action_bar(<?php echo $row -> id;?>)" onmouseout="hide_action_bar(<?php echo $row -> id;?>)">
    <td><input type="checkbox" name="delete_id[]" value="<?php echo $row->id;?>"></td>
    <td><?php echo $row->id;?></td>
    <td width="50%">
    		<?php echo $row -> username; ?><br/>
    	<div id="<?php echo 'bar'.$row -> id;?>">
    		<?php echo anchor("user/User/update/" . $row -> id, "Edit"); ?>
    		<a href="#" onclick="show_quick_edit(<?php echo $row -> id;?>)">Quick edit</a> 
    		<?php echo anchor("user/User/show/" . $row -> id, "Show"); ?>
    	</div>
    </td>
    <td><?php echo $row->first_name;?></td>
    <td><?php echo $row->last_name;?></td>
    <td><?php echo $row->email;?></td>
  </tr>
  <tr id="<?php echo "tr".$row -> id;?>"> 
  	<td colspan="4">
  		<?php echo form_open("user/User/quick_update"); ?>
  		<?php echo validation_errors();?>
  		<input type="hidden" name="id" id="id" value="<?php echo set_value('id', $row -> id); ?>"/>
  		<table>
		  <tr>
		    <td><label for="username">Username</label></td>
		    <td><input type="text" name="<?php echo 'username'.$row -> id;?>" id="<?php echo 'username'.$row -> id;?>" value="<?php echo set_value('username', $row -> username); ?>"/></td>
		  </tr>
		  <tr>
		    <td><label for="first_name">First name</label></td>
		    <td><input type="text" name="<?php echo 'first_name'.$row -> id;?>" id="<?php echo 'first_name'.$row -> id;?>" value="<?php echo set_value('first_name', $row -> first_name); ?>"/></td>
		  </tr>
		  <tr>
		    <td><label for="last_name">Last name</label></td>
		    <td><input type="text" name="<?php echo 'last_name'.$row -> id;?>" id="<?php echo 'last_name'.$row -> id;?>" value="<?php echo set_value('last_name', $row -> last_name); ?>"/></td>
		  </tr>
		  <tr>
		    <td><label for="email">Email</label></td>
		    <td><input type="text" name="<?php echo 'email'.$row -> id;?>" id="<?php echo 'email'.$row -> id;?>" value="<?php echo set_value('email', $row -> email); ?>"/></td>
		  </tr>
  		<tr>	
  			<td><input type="submit" value="Update"/></td>
  			<td><input type="button" value="Cancel" onclick="show_quick_edit(<?php echo $row -> id;?>)"/></td>
  		</tr>
	</table>
	<?php echo form_close(); ?>
  	</td>
  </tr>
    <?php endforeach;?>
    <?php endif;?>
    <tr><td colspan="4" align="center"><?php echo $pagination_link; ?></td></tr>
</table>
<input type="submit" name="delete" value="Delete" />
</form>

<script type='text/javascript' language='javascript'>
<?php
	foreach($results as $row) {
?>
show_quick_edit(<?php echo $row->id;?>);
hide_action_bar(<?php echo $row->id;?>);
<?php
}
?>
</script>